#include <stdio.h>


int countdigit(int num, int digit)
{
	int sum = 0;
	do
	{
		if (num % 10 == digit)
			sum++;
	} while (num /= 10);
	return sum;
}

int main()
{
	int number = 0, digit = 0;
	scanf("%d%d", &number, &digit);
	printf("%d", countdigit(number, digit));
	return 0;
}